package timing.ukulele;

import org.apache.pivot.beans.BXMLSerializer;
import org.apache.pivot.collections.Map;
import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Window;

import java.io.IOException;

/**
 * Hello world!
 */
public class App implements Application {
    private Window window = null;//窗口

    public static void main(String[] args) {
        DesktopApplicationContext.main(App.class, args);
    }

    @Override
    public void startup(Display display, Map<String, String> map) throws IOException, SerializationException {
//        window = new Window();//创建窗口
//        Label label = new Label();//创建标签
//        label.setText("Hello world");//设置文字
//        label.getStyles().put("color", Color.BLACK);//设置颜色
//        label.getStyles().put("font", new Font("Segoe Print", Font.ITALIC, 24));//设置字体
//        label.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);
//        label.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);//设置居中
//        window.setContent(label);//将标签添加到窗口
//        window.setTitle("Hello world");//设置窗口标题
//        window.setMaximized(true);
//        window.open(display);

        BXMLSerializer bxmlSerializer = new BXMLSerializer();
        window = (Window) bxmlSerializer.readObject(App.class, "/app.bxml");
        window.open(display);
    }

    @Override
    public boolean shutdown(boolean b) {
        if (window != null) {
            window.close();//关闭窗口
        }
        return false;
    }

    @Override
    public void suspend() {

    }

    @Override
    public void resume() {

    }
}
